Milestone 4 : Visualizations

Please submit an Rmd and either a knit PDF or html file via github with the following:

  1. Three or more visualizations

o One print quality table as requested in scenario

o One print quality plot or chart as requested in scenario

o One additional print quality table or plot of your choice (can support the requested data in the scenario, or answer a different question using the same data sources)

  1. For each visual, include

o Code used to generate visual

o Legend

o 2-3 sentence interpretation

o NOTE: please make sure visual can stand-alone, meaning it includes enough information in title, legend, and footnote so that a person who sees only the visualization could understand what is being presented

  1. PDF that is professionally prepared for presentation

o Each part of the milestone is clearly on one page (use newpage command to push to a new page)

o Only the necessary information is outputted (e.g., suppressing entire data frame outputs)

o Use of headers and sub headers to create an organized document

Loading libraries, database, and setup for visualization

1. Visualization 1 - table

datatable(data,
          caption='Vaccination Rate as of 09/14/2021, Population, 
          and Median Age by California County',
          options=list(
            pagelength=10,
            lengthMenu=c(10,20,30,58),
            order=list(1,'desc'),
            columnDefs=list(
              list(className='dt-center',targets=1:3)
              #list(visible=FALSE, targets=3)
            ),
            dom='ltip'
          ),
          rownames=FALSE,
          colnames=c("County","Vaccination Rate","Population","Median Age"),
          filter="top",
          editable=T)

County = Name of County, Vaccination Rate = Percentage rounded to the nearest tenth Population = Number of People Median Age = Number rounded to the nearest tenth

This is a table showing Vaccination Rate as of 09/14/2021, Population, and Median Age by California County. The highest vaccination rate is 85.2%, Marin county. The lowest vaccination rate is 25.3%, Lassen county.

2. Visualization 2 - plot or chart

plot_ly(
  data,
  x=~Median_Age,
  y=~Mean_Vaccination_Rate_Percentage,
  color=~County,
  type="scatter",
  mode="markers",
  text=~paste('County: ',County,'<br>Population: ',Population_2012)
) %>%
  layout(
    title="Vaccination Rate as of 09/14/2021, California Counties",
    yaxis=list(title="Vaccination Rate in Percentage"),
    xaxis=list(title="Median Age of County"),
    plot_bgcolor="azure"
  )

This is a plot of the mean vaccination rate in percentage by median age of each county’s population. Each dot represents each county, and you can also check the total population of that county when you put your cursor above each bead.

3. Visualization 3 - One additional print quality table or plot of your choice

formattable(data, col.names=c("Name of Each County","Mean Vaccination Rate in Percentage",
                              "Total Population of Each County in 2012",
                              "Median Age of Each County's Population"),
            align=c("l",rep("r",NCOL(data)-1)),
            list(
              'County'=formatter("span",style=~formattable::style(color="grey",font.weight="bold"))
            ))
Name of Each County Mean Vaccination Rate in Percentage Total Population of Each County in 2012 Median Age of Each County’s Population
ALAMEDA 78.9 1534551 36.6
ALPINE 51.2 1148 46.4
AMADOR 61.3 38354 48.2
BUTTE 52.0 222350 37.1
CALAVERAS 60.6 46212 49.1
COLUSA 57.1 21780 33.5
CONTRA COSTA 81.0 1067570 38.4
DEL NORTE 43.4 28685 39.0
EL DORADO 55.6 182494 43.5
FRESNO 58.3 944788 30.7
GLENN 48.7 28516 35.3
HUMBOLDT 59.2 136375 37.3
IMPERIAL 63.0 178091 32.0
INYO 52.0 18611 45.5
KERN 49.5 851089 30.7
KINGS 46.1 155039 31.1
LAKE 59.2 65253 45.0
LASSEN 25.3 35039 37.0
LOS ANGELES 69.8 9904341 34.8
MADERA 54.4 153025 33.1
MARIN 85.2 255509 44.5
MARIPOSA 45.4 18455 49.2
MENDOCINO 65.9 88094 41.6
MERCED 43.7 256841 29.6
MODOC 35.7 9791 46.0
MONO 73.0 14418 37.2
MONTEREY 67.3 420465 33.0
NAPA 76.2 135855 39.7
NEVADA 66.3 99951 47.5
ORANGE 71.5 3054269 36.2
PLACER 68.9 356116 40.3
PLUMAS 57.0 20000 49.5
RIVERSIDE 58.9 2227789 33.7
SACRAMENTO 65.3 1432457 34.8
SAN BENITO 62.9 56501 34.3
SAN BERNARDINO 52.2 2062041 31.7
SAN DIEGO 67.6 3137431 34.7
SAN FRANCISCO 80.8 824334 38.5
SAN JOAQUIN 57.0 688477 32.7
SAN LUIS OBISPO 60.4 271619 39.4
SAN MATEO 81.2 726677 39.2
SANTA BARBARA 67.4 423800 33.7
SANTA CLARA 85.0 1819137 36.2
SANTA CRUZ 72.9 262470 36.8
SHASTA 47.0 178831 41.8
SIERRA 42.6 3226 51.0
SISKIYOU 39.8 45200 46.8
SOLANO 64.7 418187 36.9
SONOMA 73.3 487061 39.8
STANISLAUS 52.7 518549 32.9
SUTTER 50.0 95619 34.6
TEHAMA 40.4 63757 39.5
TRINITY 40.0 14063 49.2
TULARE 50.4 448724 29.6
TUOLUMNE 62.4 55331 47.1
VENTURA 68.3 825977 36.2
YOLO 69.7 204322 30.5
YUBA 48.8 72822 32.2

This is another table using a formattable function. Each row represents each county, and all 58 counties in California are shown. Rows are in alphabetical order.

4. PDF professionally prepared for presentation

What evidence if any exists of a strong correlative relationship, and if so in what direction?

Answer: There is no correlative relationship between the median age of each county’s population and the vaccination rate. As shown in the above scatter plot, there is no clear linear relationship between the x-axis and y-axis.